package huanzhao.erp.domain.types;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author April
 * 2024/10/4 10:46
 * @version 1.0
 */
@Getter
public enum ExceptionType {
    TIMEOUT("超时"),
    LOST("丢失"),
    DAMAGE("损坏"),
    DESTROY("报损");

    @EnumValue
    @JsonValue
    private final String value;

    ExceptionType(String value) {
        this.value = value;
    }

    public static ExceptionType of(int exceptionTypeCode) {
        return switch (exceptionTypeCode) {
            case 0 -> TIMEOUT;
            case 1 -> DAMAGE;
            case 2 -> LOST;
            default -> DESTROY;
        };
    }
}
